<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Post extends CI_Controller {
	
	public function index($post_name, $typeid, $id = '')
	{
		
		$this->load->helper('url');
		$this->load->model('nav_model');
		$menu = $this->nav_model->get_nav('post', $post_name);
		
		$this->load->model('db_model');
		$this->db_model->loadTable('post');
		$post = $this->db_model->findAll(array('typeid'=>$typeid), '*', 'order desc, id asc', 0, 5);

		$names = array();
		$content = '';
		foreach($post as $loop)
		{
			$ids[] = $loop->id; 
			$names[] = $loop->name;
			
			if($content == '')
			{
				if($id === '') 
				{
					$content = $loop->content;
				}
				elseif ($id == $loop->id)
				{
					$content = $loop->content;
				}	
			}
			
		}
		
		$config['view'] = 'post_view';
		$config['menu'] = $menu;
		$config['post'] = $post;
		$config['typeid'] = $typeid;
		$config['post_name'] = $post_name;
		$config['ids'] = $ids;
		$config['names'] = $names;
		$config['content'] = $content;
		
		$this->load->view('global_view', $config);	
				
	}

}

/* End of file home.php */
/* Location: ./application/controllers/home.php */